package com.evola.dbsm.utils
{
	import com.evola.dbsm.model.ProjectBean;
	import com.evola.dbsm.model.ScriptBean;
	import com.evola.dbsm.model.UserBean;
	
	import mx.collections.ArrayCollection;
	import mx.collections.IList;

	public class MockDataSource
	{

		private static var _projects : IList;
		private static var _scripts : IList;
		
		
		public static function getProjects():IList
		{
			
			if(_projects)
					return _projects;

			var ac:ArrayCollection=new ArrayCollection();

			var project:ProjectBean=new ProjectBean();
			project.name="TravelConnect";
			project.description="Travel agency management application";
			project.createdBy = getUser();
			project.creationDate = new Date();

			ac.addItem(project);

			project=new ProjectBean();
			project.name="CBSPayroll";
			project.description="Employees and payroll management application";
			project.createdBy = getUser();
			project.creationDate = new Date();

			ac.addItem(project);
			
			_projects = ac;

			return ac;
		}

		public static function getScripts(project:ProjectBean):IList
		{
			
			if(_scripts)
					return _scripts;

			var ac:ArrayCollection=new ArrayCollection();

			var script:ScriptBean=new ScriptBean();
			script.content="SELECT * FROM somewhere";
			script.createdBy=getUser();
			script.creationDate=new Date();
			script.id = int(Math.random() * 1000);

			ac.addItem(script);

			script=new ScriptBean();
			script.content="DELETE FROM...";
			script.createdBy=getUser();
			script.creationDate=new Date();
			script.comment="Prvo treba izvrsiti sve prethodne skripte";
			script.id = int(Math.random() * 1000);

			script=new ScriptBean();
			script.content="SELECT Company, Country FROM Customers WHERE Country <> 'USA'";
			script.createdBy=getUser();
			script.creationDate=new Date();
			script.comment="Learn by examples! With our editor, you can edit the SQL, and click on a button to view the result.";
			script.id = int(Math.random() * 1000);

			ac.addItem(script);
			
			_scripts = ac;

			return ac;
		}
		
		public static function getUser() : UserBean{
			
			var user:UserBean=new UserBean();
			user.username="smrkela";
			user.name="Sasa";
			user.surname="Mrkela";
			
			return user;
		} 
		

	}
}